function numberOfSubarrays(nums: number[], k: number): number {
  const s: number[] = [0];
  const n = nums.length;
  const c: number[] = new Array(n + 1).fill(0);
  let ans = 0;
  c[s[0]]++;
  for (let i = 1; i <= n; i++) s[i] = s[i - 1] + nums[i - 1] % 2;
  for (let i = 1; i <= n; i++) {
    if (s[i] - k >= 0) ans += c[s[i] - k];
    c[s[i]]++;
  }
  return ans;
};